package igor.mass.render.renderers;

import igor.mass.model.AndroidParam;
import igor.mass.render.renderables.AndroidRenderable;

import java.util.HashMap;

import android.content.Context;

public class RendererFactory {

	private static HashMap<String, AndroidRenderer> availableRenderers;
	
	static {
		availableRenderers = new HashMap<String, AndroidRenderer>();
		availableRenderers.put("String", new StringRenderer());
		availableRenderers.put("int", new IntegerRenderer());
		availableRenderers.put("boolean", new BooleanRenderer());
		availableRenderers.put("slider", new SliderRenderer());
	}
	
	public static AndroidRenderer getRendererFor(Context context, AndroidParam param, Object initialValue){
		AndroidRenderer renderer;
		
		if (param.type.equals("int")&& param.percentage==true) {
			renderer = availableRenderers.get("slider").clone();
			renderer.initialise(context, param, initialValue);
			return renderer;
		}
		
		renderer = availableRenderers.get(param.type).clone();
		renderer.initialise(context, param, initialValue);
		return renderer;
	}
}
